package com.acwing.partition21;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/6/2 10:03
 */
public class AC2023连接奶牛 {

    private static final int N = 11;
    private static int[][] p = new int[N][2];
    //f[i][j][k]表示当前状态i（二进制位为1表示在这个节点旋转过），最后一个到达的点是j，且到达最后一个点的方向是k的方案数
    private static int[][][] f = new int[1 << N][N][4];
    private static int n;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt();
        for (int i = 0; i < n; i++) p[i] = new int[]{nextInt(), nextInt()};
        //初始化原点能直接到达的点
        for (int i = 0; i < n; i++) {
            int d = getDir(p[n], p[i]);
            if (d == -1) continue;
            f[1 << i][i][d] = 1;
        }
        writer.println(resolve());
        writer.flush();
    }

    private static int resolve() {
        //枚举当前的状态、最后一个到达的点（需要已经旋转过）、到达最后一个点的方向、下一个点
        for (int s = 0; s < 1 << n; s++) {
            for (int i = 0; i < n; i++) {
                if ((s >> i & 1) == 0) continue;
                for (int fd = 0; fd < 4; fd++) {
                    for (int j = 0; j < n; j++) {
                        if ((s >> j & 1) == 1) continue;
                        int td = getDir(p[i], p[j]);
                        //如果不能直接到达或者方向和之前的方向一样，则跳过状态转移
                        if (td == -1 || td == fd) continue;
                        f[s | (1 << j)][j][td] += f[s][i][fd];
                    }
                }
            }
        }
        int res = 0;
        for (int i = 0; i < n; i++) {
            for (int fd = 0; fd < 4; fd++) {
                int td = getDir(p[i], p[n]);
                if (td == -1 || td == fd) continue;
                res += f[(1 << n) - 1][i][fd];
            }
        }
        return res;
    }

    private static int getDir(int[] a, int[] b) {
        //得到a到b的方向，如果不能到达返回-1
        int res = -1;
        if (a[0] == b[0]) {
            if (a[1] < b[1]) res = 0;
            else res = 2;
        } else if (a[1] == b[1]) {
            if (a[0] < b[0]) res = 1;
            else res = 3;
        }
        return res;
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
